
<div id="hand-driver-edit">
    <div class="hint-content" style="height:283px;">
        <div class="one-case" style="width: 100%;">
            <input type="hidden" data-bind="value:id" />
            <div class="hint-text">
                <label>设备名称</label>
                <input type="text" class="k-textbox"  data-bind="value:deviceName" maxlength="20" validationMessage="设备名称为必填且不能包含特殊字符"  required pattern="^[\u4e00-\u9fa5A-Za-z0-9-_]*$" />
            </div>
            <div class="hint-text">
                <label>设备编号</label>
                <input type="text" class="k-textbox"  data-bind="value:deviceCode" maxlength="20" validationMessage="设备编号为必填且不能包含特殊字符"  required pattern="^[\u4e00-\u9fa5A-Za-z0-9-_]*$" />
            </div>
            <div class="hint-text">
                <label>MAC地址</label>
                <input type="text" class="k-textbox"  data-bind="value:macAddress" validationMessage="MAC地址为必填且必须格式正确(xx:xx:xx:xx:xx:xx)"  required pattern="^[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]:[0-9A-F][0-9A-F]$" />
            </div>
            <div class="hint-text">
                <label>软件版本</label>
                <input type="text" class="k-textbox"  data-bind="value:softwareVersion" />
            </div>
            <div class="hint-text">
                <label>状态</label>
                <input type="text" id="hand-device-status" data-bind="value:status">
            </div>
            <div class="hint-text">
                <label>备注</label>
                <textarea class="k-textbox" style="width:470px; height: 50px;" data-bind="value:remark"></textarea>
            </div>
        </div>
    </div>
    <div class="basicInfo-btn">
        <button class="save" data-bind="click:save_info">保存</button>
        <button class="cancel" data-bind="click:cancel">取消</button>
    </div>
</div>
<script>
    var HandDriverEdit = function($parent) {
        this.$parent = $parent;
        this.sysUtils = new kendoUtils();
        this.init();
        return this;
    }
    HandDriverEdit.prototype = {
        init : function() {
            var bindField = this.sysUtils.getBindFieldArray(this.$parent);
            var bindFunction = [
                {fName : "save_info", fs : this.saveInfo},
                {fName : "cancel" , fs : function(){$("#"+handDriver.editDiv).data("kendoWindow").close();}}
            ];
            this.bindBaseModels = new bindBaseModel(null, bindField, bindFunction, null);
            this.sysUtils.bindDoucment(this.bindBaseModels, this.$parent, this);

            var statusStart = Utils.getModelValueByModelKey(BASIS.DATA_STATUS.DATA_STATUS_START);
            Utils.createDataDictDropDownList([{div:this.$parent.find("#hand-device-status"),parentModelKey:BASIS.DATA_STATUS.ROOT,select:statusStart}],this);

            this.loadData();
        },
        loadData : function() {
            if (handDriver.editResult == null) return;
            this.sysUtils.setBindFieldValue(handDriver.editResult);
            if (!handDriver.isEdit) {
                this.$parent.find('input[type]').attr('disabled', 'disabled');
                this.$parent.find('textarea').attr('disabled', 'disabled');
                this.$parent.find('#hand-device-status').data("kendoDropDownList").enable(false);
                this.$parent.find('.save').remove();
            }
        },
        saveInfo : function(e) {
            var _this = $(e.target).data("that");
            var params = _this.sysUtils.getBindDocJson();
            if (validityForm(_this.$parent)) {
                if (handDriverEdit.editResult) {
                    params.id = handDriver.editResult.id;
                }
                JsonpAjax(baseApiPath + "hand_driver/update?isEdit="+handDriver.isEdit, JSON.stringify(params), "json", function(res) {
                    $("#" + handDriver.editDiv).data("kendoWindow").close();
                    handDriver.findGridData();
                });
            }

        }
    }
    var handDriverEdit = new HandDriverEdit($("#hand-driver-edit"));
</script>